import {createI18n} from "vue-i18n";
import zh from "./modules/zh.ts";
import en from "@/plugins/i18n/modules/en.ts";

const datetimeFormats = {
    'en-US': {
        short: {
            year: 'numeric', month: 'short', day: 'numeric'
        },
        long: {
            year: 'numeric', month: 'short', day: 'numeric',
            weekday: 'short', hour: 'numeric', minute: 'numeric'
        }
    },
    'ja-JP': {
        short: {
            year: 'numeric', month: 'short', day: 'numeric'
        },
        long: {
            year: 'numeric', month: 'short', day: 'numeric',
            weekday: 'short', hour: 'numeric', minute: 'numeric', hour12: true
        }
    }
}
const i18n = createI18n({

    datetimeFormats: datetimeFormats,
    legacy: false,
    locale: localStorage.getItem('lang') || 'zh',
    fallbackLocale: 'en',
    globalInjection: true,
    messages: {
        zh, en,
    },
    warnHtmlMessage: true,
    allowComposition:true
});

export default i18n;